<div class="yuSuo clearfix" style="float:left;">
    <form id="searchFrom">
      <?php if($params['status']== 2): ?>
         <select name="bc_city" id="bc_city1" >
             <option value="">请选择城市所在地</option>
            <?php foreach ($bc_city as $k => $v): ?>
                <option value="{$k}"
                <?php if ($params['bc_city'] == $k): ?>
                    selected = "selected"
                <?php endif ?>
                >{$v}</option>
            <?php endforeach ?>
          </select>
        <?php endif;?>
        <input id="status" name="status" type="hidden" value="{$params.status}"/>
        <?php if($params['status']== 1): ?>
        <input type="text" name="search_key" value="{$params.search_key}"  placeholder="集团名称,集团地址,联系人,联系电话"  class="suoDian suoDian1" style="width:350px">
         <?php elseif($params['status']==2): ?>
        <input type="text" name="search_key" value="{$params.search_key}"  placeholder="4S店名称,4S店地址,联系人,联系电话,4S店开发人,所属集团"  class="suoDian suoDian1" style="width:350px">
        <?php endif;?>
        <input type="button" onclick="search();" value="搜索" class="suoSou" style="width:80px;">
    </form>
</div>
<div class="xinzeng clearfix" style="float:right;">
  <?php if($params['status']==1): ?>
    <a class="newBtn" href="javascript:;" onclick="popup()" >添加集团</a>
  <?php elseif($params['status']==2): ?> 
    <a class="newBtn" href="/Fours/add_fm" >添加4s店</a>
  <?php endif;?>
</div>

<div class="yuList">
  <table class="table table-bordered">
    <thead>
      <tr>
        
        <?php if($params['status']==1): ?> 
          <th>集团id</th>
          <th>集团名称</th>
          <th>集团地址</th>   
        <?php elseif($params['status']==2): ?>
          <th>4S店id</th>   
          <th>4S店名称</th>
          <th>4S店地址</th> 
        <?php endif;?>      
        <th>联系人</th>
        <th>联系电话</th>
        <?php if($params['status']==2): ?>
        <th>4S店开发人</th>  
        <th>所属集团</th>
        <th>所在城市</th>  
        <?php endif;?>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <volist name="list" id="list" key="k">
        <tr>
        <?php if($params['status']==1): ?> 
          <td>{$list.bid}</td>
        <?php elseif($params['status']==2): ?>  
          <td>{$list.fid}</td>
        <?php endif;?>       
        <?php if($params['status']==1): ?> 
          <td>{$list.b_name}</td> 
        <?php elseif($params['status']==2): ?>   
          <td>{$list.f_name}</td> 
        <?php endif;?> 
          <td>{$list.addr}</td>  
          <td>{$list.contact}</td> 
          <td>{$list.phone}</td>
          <?php if($params['status']==2): ?>
          <td>{$list.real_name}</td>
          <td>{$list.b_name}</td>
          <td>{$bc_city[$list['city']]}</td>
          <?php endif;?>
           <td>
            <?php if($params['status']==1): ?>
              <a href="/Fours/bm_eidt/bid/{$list.bid}" >编辑</a>
              <a href="javascript:" onclick="get_branch(2,{$list.bid});">下属4S店</a>
              <a href="/Fours/add_bf/bid/{$list.bid}" >关联4S店</a>
            <?php elseif($params['status']==2): ?>
               <?php if($edit_auth || $emp_id==$list['developer']):?>
                <a href="/Fours/fm_eidt/fid/{$list.fid}">编辑</a>
               <?php endif;?>
            <?php endif;?>
           </td>       
        </tr>
      </volist>
    </tbody>
  </table>
 </div>
 <div class="pageFaye"><div class="pager">{$page}</div><div class="clear"></div></div>
</div>
<script>
</script>

<script>
 function get_branch(status,bid){
     $('input[name=status]').val(status);
     $('input[name=bid]').val(bid);
     $('#branch').attr('class','yuCurrent');
      $('#branch').siblings().attr('class','');
     $.get("/Fours/get_fbmanger_list/bid/"+bid,{"status":status},function(data){
        $("#listBox").html(data);  
     },"html");
 }

$(".tanShang ul li .quxiao").click(function(){
    $(".tanShang").fadeOut();
    $(".yunBei").css("display","none");
});
function resetSearch(){
  $("#start_time").val('');
  $("#end_time").val('');
  $("input[name='order_no']").val('');
}

//表单弹窗
  function popup() {
      $(".yunBei").fadeIn();
      $(".tanShang").fadeIn(); 
      $("#b_id").select2();
      $("#bc_city").select2();
  }


  //添加4s账号提交
    $("#add_fm").on('click', function () {
        var f_name = $('input[name=f_name]').val();
        var addr = $('input[name=f_addr]').val();
        var contact = $('input[name=contact]').val();
        var phone = $('input[name=phone]').val();
        var developer = $('input[name=developer]').val();
        var b_id = $('#b_id').val();
        var bc_city = $('#bc_city').val();
        var bank_name = $("#bank_name").val();
        var card_no = $("#card_no").val();
        var account_name = $("#account_name").val();
        var param = {
            'f_name': f_name,
            'addr': addr,
            'contact': contact,
            'phone': phone,
            'developer': developer,
            'b_id': b_id,
            'bc_city':bc_city,
            'bank_name':bank_name,
            'card_no':card_no,
            'account_name':account_name,
        };
        $.post('/fours/add_fm', param, function (data) {
            if (data.code == '200') {
                $(".yunBei").css("display", "none");
                $(".tanShang").fadeOut();
                btn_alert(data.msg);
                get_list(2);
            } else {
                shibai_alert(data.msg);
            }
        }, "json");

    });


</script>